/**
 *	Copyright (c) 2009, SpLib.net
 * 	All rights reserved.
  	
 * 	Author:6spring
 * 	About:绘图对象状态
*/

package SpLib.display
{
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	public class Graphics2DState
	{	
		public static const TYPE_NORMAL:String = "Normal";
		public static const TYPE_VIEW:String = "View";
		
		protected var m_sType:String = TYPE_NORMAL;
		protected var m_Rect:Rectangle = new Rectangle;	
		protected var m_DestImg:flash.display.BitmapData = null;
		protected var m_Trans:Point = new Point;
		protected var m_Clip:Rectangle = new Rectangle;
		protected var m_ViewPos:Point = null;
	
		public function Graphics2DState()
		{
			m_Trans.x = 0;
			m_Trans.y = 0;
		}
		
		public function get rect():Rectangle
		{
			return m_Rect.clone();
		}
		
		public function get clip():Rectangle
		{
			return m_Clip.clone();
		}
		
		public function get clip_width():int
		{
			return m_Clip.width;
		}
		
		public function get clip_height():int
		{
			return m_Clip.height;
		}
		
		public function Copy(rhs:Graphics2DState):void
		{
			m_sType = rhs.m_sType;
			m_Rect = rhs.m_Rect.clone();
			m_DestImg = rhs.m_DestImg;
			m_Trans = rhs.m_Trans.clone();
			m_Clip = rhs.m_Clip.clone();
			
			m_ViewPos = null;
			
			if(rhs.m_ViewPos!=null)
			{
				m_ViewPos = rhs.m_ViewPos.clone();
			}
		}
		
		public function clone():Graphics2DState
		{
			var g:Graphics2DState = new Graphics2DState();
			g.Copy(this);
			return g;
		}
		
		public function get data():BitmapData
		{
			return m_DestImg;
		}
	}
}